USE [NguyenHoa]
GO

------------------------------------------------------------------
--							@tblAdvertisement
-----------------------------------------------------------------
IF EXISTS (SELECT * FROM sys.objects WHERE object_id=object_id(N'[dbo].[_tblAdvertisement_GetByTypeAndLanguage]') and type IN (N'PC', N'P'))
DROP PROCEDURE [dbo].[_tblAdvertisement_GetByTypeAndLanguage]
GO

CREATE PROCEDURE [dbo].[_tblAdvertisement_GetByTypeAndLanguage]
(
	@Type				CHAR(1),
	@LanguageId INT,
	@IsShow			BIT
)
AS
		SELECT A.Id, A.ImagePath, A.Website, A.Description, A.Position, AL.Name
		FROM tblAdvertisement A JOIN tblAdvertiseLocale AL ON A.Id = AL.AdvertiseId AND AL.LanguageId = @LanguageId
		WHERE (@Type IS NULL OR @Type='' OR @Type=[Type]) AND
					@IsShow = [IsShow]
GO
-----------------------------------------------------------------

IF EXISTS (SELECT * FROM sys.objects WHERE object_id=object_id(N'[dbo].[_tblAdvertisement_GetByType]') and type IN (N'PC', N'P'))
DROP PROCEDURE [dbo].[_tblAdvertisement_GetByType]
GO

CREATE PROCEDURE [dbo].[_tblAdvertisement_GetByType]
(
	@Type		CHAR(1),
	@IsShow BIT
)
AS
		SELECT *
		FROM	tblAdvertisement
		WHERE (@Type IS NULL OR @Type='' OR @Type=[Type]) AND
					(@IsShow = [IsShow])
--		ORDER BY [Name], [EnglishName]
GO
